package leetcode.day;

public class ComplexNumberMultiply {

    public static void main(String[] args) {
        System.out.println(complexNumberMultiply("1+-1i", "1+-1i"));
    }
    public static String complexNumberMultiply(String num1, String num2) {
        String res = "";
        Integer a = Integer.parseInt(num1.split("\\+")[0]);
        Integer b = Integer.parseInt(num2.split("\\+")[0]);
        // 虚部数字
        Integer c =Integer.parseInt(num1.split("\\+")[1]
                .substring(0,num1.split("\\+")[1].length()-1));
        Integer d =Integer.parseInt(num2.split("\\+")[1]
                .substring(0,num2.split("\\+")[1].length()-1));
        res += (a*b)-(c*d)+"+"+(a*d+b*c)+"i";
        return res;
    }

}
